package br.gendi.rcp.actions;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;

import br.gendi.beans.BaseGenomica;
import br.gendi.rcp.ICommandIds;
import br.gendi.rcp.NavigationView;

public class DesabilitarAction extends Action {

    private final IWorkbenchWindow window;

    public DesabilitarAction(String text, IWorkbenchWindow window, String image) {
        super(text);
        this.window = window;
        // The id is used to refer to the action in a menu or toolbar
        setId(ICommandIds.CMD_DESABILITAR);
        // Associate the action with a pre-defined command, to allow key bindings.
        setActionDefinitionId(ICommandIds.CMD_DESABILITAR);
        setImageDescriptor(br.gendi.rcp.Activator.getImageDescriptor(image));
    }

    public void run() {
    	//TODO:
        //MessageDialog.openInformation(window.getShell(), "Open", "Sites atualizados!");
    	
    	IViewPart[] views = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViews();
		NavigationView nv = null;
		for (int i=0; i<views.length; i++)
			if (views[i] instanceof NavigationView) {
				nv = (NavigationView) views[i];
				break;
			}
		try {
			nv.habilitarTodos(false);
			nv.carregarItens();
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
}